package sg.edu.nus.iss.jass.gui;

import javax.swing.JPanel;

import sg.edu.nus.iss.jass.gui.component.MessageLabel;
import sg.edu.nus.iss.jass.gui.component.TitleLabel;
/**
 * <h5>HeaderPanel to load the Header for the actual function GUI form</h5>
 * This  class is derived from JPanel to create the Header Panel .This Panel consists of 
 * TitleLabel to show the Title of the Function and 
 * MessageLabel to show resultant action message on the form after the user selecting any action.
 * @author Kafoor Sammil
 * 
 */

public class HeaderPanel extends JPanel{
	
    /**
	 * 
	 */
	private static final long serialVersionUID = -2880553314264506643L;
	private static int HEIGHT = 20;

	private String titleText;
	private String msgText;
	private MessageLabel msgLabel = null;
	private TitleLabel title = null;
	
	/**
     * Constructor to create the HeaderPanel for the Form with the title passed as argument .
     * @param titleTxt
	 *            string to set the title of the Form . 
     */ 
	public HeaderPanel(String titleTxt){
		super(null);
		title = new TitleLabel(titleTxt);
		title.setBounds(10, 15, 200, HEIGHT);
		add(title);
		
		msgLabel = new MessageLabel("");
		msgLabel.setBounds(10, 45, 600, HEIGHT);
		add(msgLabel);
	}
	
	
	/**
	 * To get the current title of the Form
	 * @return the titleText
	 */
	public String getTitleText() {
		return titleText;
	}

	/**
	 * To set the  title of the Form 
	 * @param titleText the titleText to set
	 */
	public void setTitleText(String titleText) {
		this.titleText = titleText;
		
		
	}

	/**
	 * To get the current message of the Form 
	 * @return the msgText
	 */
	public String getMsgText() {
		return msgText;
	}

	/**
	 * To set the  message of the Form  
	 * @param msgText
	 * 			 the msgText to set
	 * @param success
	 * 			 If true, show the message in green color, show the message in red otherwise.
 
	 */
	public void setMsgText(String msgText,boolean success) {
	    this.msgText = msgText;
		
	    this.remove(msgLabel);
		msgLabel = new MessageLabel(titleText,success);
		msgLabel.setBounds(10, 45, 600, HEIGHT);
		add(msgLabel);
		
		msgLabel.setText(msgText);
		this.validate();
	}
	
	/**
	 * To clear the message on the form.  
	 */
	public void clearMsg() {
		msgLabel.setText("");
		this.validate();
	}
}
